package com.stone.back.dish.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.stone.back.dish.dao.IComboDao;
import com.stone.back.dish.entity.BfCombo;
import com.stone.back.dish.entity.BfComboDish;
import com.stone.base.entity.Page;

/**
 * 套餐管理
 * @author Stone P
 *
 */
@Service
public class ComboService implements IComboService {
	@Autowired
	private IComboDao comboDao;

	/**
	 * 查询套餐分页信息
	 * @param pageNumber	页数
	 * @param comboChName	中文套餐名
	 * @param comboEnName	英文套餐名
	 * @param priceMin		单价
	 * @param priceMax		单价
	 * @param startDate		创建日期
	 * @param endDate		创建日期
	 * @return
	 */
	@Override
	public Page selectComboPage(int pageNumber, String comboChName, String comboEnName, String priceMin, String priceMax, String startDate, String endDate) {
		return comboDao.selectComboPage(pageNumber, comboChName, comboEnName, priceMin, priceMax, startDate, endDate);
	}
	
	/**
	 * 查询套餐列表
	 * @return
	 */
	@Override
    public List<BfCombo> selectComboList() {
		return comboDao.selectComboList();
    }

	/**
	 * 增加套餐
	 * @param combo	套餐信息
	 * @return
	 */
	@Override
	public Integer addCombo(BfCombo combo) {
		Integer comboId = this.comboDao.addCombo(combo);
		return comboId;
	}

	/**
	 * 套餐和菜品关系
	 * @param comboDish	套餐菜品信息
	 * @return
	 */
	@Override
	public Integer addComboDish(BfComboDish comboDish) {
		Integer comboDishId = this.comboDao.addComboDish(comboDish);
		return comboDishId;
	}

	/**
	 * 修改套餐
	 * @param combo	套餐信息
	 * @return
	 */
	@Override
	public void updateCombo(BfCombo combo) {
		this.comboDao.updateCombo(combo);
	}

	/**
	 * 套餐和菜品关系
	 * @param comboDish	套餐菜品信息
	 * @return
	 */
	@Override
	public void deleteComboDish(int comboId) {
		this.comboDao.deleteComboDish(comboId);
	}

	/**
	 * 查询套餐详情
	 * @param comboId	套餐Id
	 * @return
	 */
	@Override
	public BfCombo selectComboDetail(int comboId) {
		BfCombo combo = this.comboDao.selectComboDetail(comboId);
		return combo;
	}

	/**
	 * 查询套餐和菜品关系详情
	 * @param comboId	套餐Id
	 * @return
	 */
	@Override
	public List<BfComboDish> selectComboDishDetail(int comboId) {
		List<BfComboDish> comboDishList = this.comboDao.selectComboDishDetail(comboId);
		return comboDishList;
	}

	/**
	 * 删除套餐
	 * @param comboId	套餐Id
	 * @return
	 */
	@Override
	public void deleteCombo(int comboId) {
		BfCombo combo = this.comboDao.selectComboDetail(comboId);
		combo.setStatus(0);
		comboDao.updateCombo(combo);
	}
}
